﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MVC2_Test.Models;

namespace MVC2_Test.Controllers
{
    public class HomeController : Controller
    {
        //
        // GET: /Home/

        public ActionResult Index()
        {
            int hour = DateTime.Now.Hour;
            ViewData["greeting"] = (hour < 12 ? "Good morning" : "Good afternoon");
            return View();
        }


        // GET: /Home/RSVPForm

        public ViewResult RSVPForm()
        {
            Member mb = new Member();
            mb.AddMember("Stephen");

            return View();
        }


        // POST: /Home/RSVPForm

        [HttpPost]
        public ViewResult RSVPForm(GuestResponse guestResponse)
        {
            if (ModelState.IsValid)
            {
                guestResponse.Submit();

                // Thanks 뷰로 렌더링
                return View("Thanks", guestResponse);
            }
            else // 유효성 검사 오류, 입력폼 다시 제출
            {
                return View();
            }

        }
    }
}
